package com.owbtgad.common.base

import androidx.fragment.app.Fragment
import com.owbtgad.common.R
import java.util.*

/**
 * 暂时用不到，未完
 * @param <T>
</T> */
abstract class FragmentActivity<T : Fragment?> : BaseActivity() {
    protected var fragments: MutableList<T> = ArrayList()
    protected var mBaseFragment: Fragment? = null
    override fun getContentLayout(): Int {
        return R.layout.fragment
    }

    protected fun showFragment(fragment: T) {
        mBaseFragment = fragment
        hideFragment()
        if (fragment!!.isAdded) {
            supportFragmentManager.beginTransaction()
                .show(fragment).commit()
        } else {
            fragments.add(fragment)
            supportFragmentManager.beginTransaction()
                .add(R.id.lay_fragment, fragment)
                .show(fragment).commit()
        }
    }

    protected fun hideFragment() {
        for (fragment in fragments) {
            supportFragmentManager.beginTransaction().hide(fragment!!).commit()
        }
    }
}